package com.xxxy.jsq.action.user;

import com.xxxy.jsq.dao.UserDao;
import com.xxxy.jsq.model.User;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "deleteUserServlet", value = "/deleteUserServlet")
public class deleteUserServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public deleteUserServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        User model = new User();
        UserDao dao = new UserDao();
        //获取页面数据
        Long cid = Long.valueOf(request.getParameter("cid"));
        String flag = dao.deleteById(cid);
        PrintWriter out = response.getWriter();
        out.print(flag);
        out.flush();
        out.close();
    }
    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
